<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class RefundsController extends Controller
{
    public function store(Request $request)
    {
        return $this->handle($this->getService('Refund')->add());
    }

    public function update(Request $request, $id)
    {
        return $this->handle($this->getService('Refund')->edit($id));
    }

    public function show($id)
    {
        return $this->handle($this->getService('Refund')->getRefundByOrderId($id));
    }
//退货详情
    public function getRefundList(){

        $user_id = $this->getUserId('users');
        $order_id = \request()->order_id;
//        $stroe_id = $this->getService('Store')->getStoreId()['data'];
        $refund_model = $this->getService('Refund', true);
        $refund_list = $refund_model::with('order')
            ->where('order_id',$order_id)
//            ->where('user_id', $user_id)
//            ->where('store_id', $stroe_id)
            ->first();
        if ($refund_list){
            return $this->success($refund_list);
        }else{  //没有数据
            return $this->error('未查到数据');

        }

    }
}
